﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCDuLieuDetail.ascx.cs"
    Inherits="Viewer.Code.UserControls.UCDuLieuDetail" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="~/Code/UserControls/AddCommonCode.ascx" TagName="AddCommonCode"
    TagPrefix="uc" %>
<ext:XScript ID="XScipt1" runat="server">
    <script type="text/javascript">
         var prepare= function (grid, toolbar, rowIndex, record) {
        
         if(#{hdType}.value=='View')
         {
        
             var button1=toolbar.items.get(0).menu.items.items[1];
             var button2=toolbar.items.get(0).menu.items.items[2];
             if(button1!=null)
             {button1.disable();}
              if(button2!=null)
             {button2.disable();}
             }
        };                
        function ConfirmDeleteNhanVien(command,record) {
            Ext.MessageBox.confirm('Thông báo', 'Bạn có chắc chắn xóa record này ko?', function doDel2(btn) {
                if (btn == 'yes') {
                     Ext.net.Mask.show();
                    #{storeDulieuDetail}.remove(record);
                    #{DirectMethods}.ShowDialog('Delete',record.id);
                }
            });
        }
      
        </script>
</ext:XScript>
<ext:Window ID="wdDuLieuDetail" runat="server" Title="List Code" Width="650" Hidden="true"
    Height="510" Modal="true" BodyCssClass="window">
    <Items>
        <ext:Hidden ID="hdType" runat="server" />
        <ext:Hidden ID="hdLoaiMa" runat="server" />
        <ext:Container ID="Container1" runat="server" Layout="FormLayout" LabelWidth="50"
            StyleSpec="background-color:white;">
            <Items>
                <ext:TextField ID="txtLoaiMa" runat="server" FieldLabel="Loại mã" />
                <ext:TextField ID="txtGhiChu" runat="server" Text="" FieldLabel="Ghi Chú">
                </ext:TextField>
            </Items>
        </ext:Container>
        <ext:BoxComponent ID="BoxComponent2" runat="server" />
        <ext:GridPanel ID="grdCommonCode" runat="server" Height="400">
            <ColumnModel>
                <Columns>
                    <ext:CommandColumn Width="40">
                        <Commands>
                            <ext:GridCommand>
                                <Menu>
                                    <Items>
                                        <ext:MenuCommand CommandName="View" Text="Xem chi tiết" Icon="LayoutHeader" />
                                        <ext:MenuCommand CommandName="Edit" Text="Sửa" Icon="ApplicationEdit" />
                                        <ext:MenuCommand CommandName="Delete" Text="Xóa" Icon="Delete" />
                                    </Items>
                                </Menu>
                            </ext:GridCommand>
                        </Commands>
                        <PrepareToolbar Fn="prepare" />
                    </ext:CommandColumn>
                    <ext:Column Width="100" Header="Chuỗi Mã" DataIndex="CodeString" />
                    <ext:Column Width="100" Header="Khóa Mã" DataIndex="CodeKey" />
                    <ext:Column Width="100" Header="Giá Trị Mã" DataIndex="CodeValue" />
                    <ext:Column Width="100" Header="Loại Mã" DataIndex="TenCodeIdType" />
                    <ext:Column Width="100" Header="Mã Cha" DataIndex="TenMaCha" />
                    <ext:Column Width="100" Header="Ghi Chú" DataIndex="GhiChu" />
                </Columns>
            </ColumnModel>
            <Listeners>
                <Command Handler="if(command=='View'){#{DirectMethods}.ShowDialog('View',record.id);} else if(command=='Edit'){#{DirectMethods}.ShowDialog('Edit',record.id);}else if(command=='Delete'){ConfirmDeleteNhanVien(command,record);}" />
            </Listeners>
            <Store>
                <ext:Store ID="storeDulieuDetail" runat="server">
                    <Reader>
                        <ext:JsonReader IDProperty="CodeID">
                            <Fields>
                                <ext:RecordField Name="CodeIDCha" />
                                <ext:RecordField Name="CodeIDType" />
                                <ext:RecordField Name="CodeKey" />
                                <ext:RecordField Name="CodeString" />
                                <ext:RecordField Name="CodeValue" />
                                <ext:RecordField Name="GhiChu" />
                                <ext:RecordField Name="TenMaCha" />
                                <ext:RecordField Name="TenCodeIdType" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20">
                </ext:PagingToolbar>
            </BottomBar>
            <TopBar>
                <ext:Toolbar ID="Toolbar" runat="server" LabelAlign="Right">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Tạo mới" IconAlign="Left" Icon="Add">
                            <Listeners>
                                <Click Handler=" Ext.net.Mask.show();#{DirectMethods}.ShowDialog('AddNew','')" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
        </ext:GridPanel>
    </Items>
    <Buttons>
        <ext:Button ID="btnSave" runat="server" Text="Lưu" Icon="Disk">
            <Listeners>
                <Click Handler="Ext.net.Mask.show();" />
            </Listeners>
            <DirectEvents>
                <Click OnEvent="btnSave_Click">
                </Click>
            </DirectEvents>
        </ext:Button>
        <ext:Button ID="Button1" runat="server" Text="Đóng" Icon="Cancel">
            <Listeners>
                <Click Handler="#{wdDuLieuDetail}.hide();" />
            </Listeners>
        </ext:Button>
    </Buttons>
</ext:Window>
<uc:AddCommonCode runat="server" ID="AddCommonCode" />
